package interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.plugin.activerecord.Db;
import model.Category;

import java.util.List;

/**
 * Created by Administrator on 2018/6/1 0001.
 */
public class CategoryNavbarInterceptor implements Interceptor {

    @Override
    public void intercept(Invocation inv) {
        String sql = Db.getSql("getAllCategory");
        List<Category> categories = Category.dao.find(sql);
        inv.getController().setAttr("categories", categories);
        inv.invoke();
    }
}
